- return unless @project.licensed_feature_available?(:product_analytics) && Feature.enabled?(:product_analytics_admin_settings) && current_user.can?(:modify_product_analytics_settings, @project) && Feature.enabled?(:product_analytics_dashboards, @project)
- data = analytics_project_settings_data(@project).merge(onboarding_path: project_analytics_dashboards_path(@project, vueroute: 'product-analytics-onboarding'))

%h4
  = s_('ProjectSettings|Product analytics')

.gl-mb-3
  #js-product-analytics-instrumentation-settings{ data: data }

%h5
  = s_('ProjectSettings|Connect your instance')
%p
  = s_('ProjectSettings|Override instance analytics configuration for this project')

= gitlab_ui_form_for @project, url: project_settings_analytics_path(@project, anchor: 'js-analytics-instance-settings'), html: { class: 'fieldset-form', id: 'product-analytics-settings', autocomplete: 'off' } do |f|
  = f.fields_for :project_setting do |settings|
    %fieldset
      = render partial: 'projects/settings/analytics/configurator_settings', locals: { f: settings }
      .form-group
        = settings.label :product_analytics_data_collector_host, s_('ProjectSettings|Collector host'), class: 'label-light'
        = settings.url_field :product_analytics_data_collector_host, class: 'form-control gl-form-input', placeholder: 'https://collector.gitlab.com'
        .form-text.text-muted
          = s_('ProjectSettings|The host of your data collector instance.')
      .form-group
        = settings.label :cube_api_base_url, s_('ProjectSettings|Cube API URL'), class: 'label-light'
        = settings.url_field :cube_api_base_url, class: 'form-control gl-form-input', placeholder: 'https://cube.gitlab.com'
        .form-text.text-muted
          = s_('ProjectSettings|The URL of your Cube instance.')
      .form-group
        .js-input-copy-visibility{ data: cube_api_key_data(form_name: 'project[project_setting_attributes]', value: @project.project_setting.cube_api_key) }
  = f.submit _('Save changes'), pajamas_button: true
